/*
 * Powered By [rapid-framework]
 * Csdn Code: generate simple CRUD code in single table.
 * Since 2015 - 2017
 */

BUI.use('common/page');
BUI.use([ 'common/search', 'bui/overlay', 'bui/grid', 'bui/data', 'bui/form' ],
		function(Search, Overlay, Grid, Data, Form) {

			// 查询表单
			var form = new Form.Form({
				srcNode : '#searchForm'
			}).render();
			// 定义表头

		});

$('#btnExport').click(function() {
	// var formData = new FormData($("#uploadFile"));
	jQuery.ajax({
		type : 'POST',
		url : "listchanneExport",
		data : $('#searchForm').serialize(),
		async : false,
		datatype : 'json',
		success : function(data) {
			var result = jQuery.parseJSON(data);
			window.location.href="/creditcat-admin/count/downExcel?fileName="+result.fileName;
			// download(result.fileName);
		},
		error : function(e) {
			alert("错误！！");
		}
	});
});
function download(fileName) {
	jQuery.ajax({
		type : 'POST',
		url : "downExcel",
		data : {
			"fileName" : fileName
		},
		datatype : 'json',
		success : function(data) {
			alert('下载成功！');
			var result = jQuery.parseJSON(data);
		},
		error : function(e) {
			alert("错误！！");
		}
	});
}